home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
ISSUE23
/
SURVIVE
/
fmAllo.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-05-19
|
4KB
|
145 lines
unit fmAllo;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls, uBase, uAllo, dmData;
type
TfrmPaymentAllocation = class(TForm)
grpSummary: TGroupBox;
grpCredits: TGroupBox;
btnPost: TButton;
btnCancel: TButton;
btnDefault: TButton;
grdSummary: TStringGrid;
grdCredits: TStringGrid;
procedure grdSummaryTopLeftChanged(Sender: TObject);
procedure grdCreditsTopLeftChanged(Sender: TObject);
procedure grdCreditsSetEditText(Sender: TObject; ACol, ARow: Longint;
const Value: string);
private
public
AllocationInfo: TAllocationInfo;
procedure PopulateForm;
end;
var
frmPaymentAllocation: TfrmPaymentAllocation;
function ShowPaymentAllocationDlg(aAllocInfo: TAllocationInfo): TModalResult;
implementation
{$R *.DFM}
{ TfrmPaymentAllocation }
function ShowPaymentAllocationDlg(aAllocInfo: TAllocationInfo): TModalResult;
begin
Application.CreateForm(TfrmPaymentAllocation, frmPaymentAllocation);
try
with frmPaymentAllocation do begin
AllocationInfo := aAllocInfo;
PopulateForm;
Result := ShowModal;
end;
finally
frmPaymentAllocation.Release;
end;
end;
procedure TfrmPaymentAllocation.PopulateForm;
var
I, J: Integer;
TotalPayment: LongInt;
begin
with grdSummary do begin
Cells[0, 1] := 'Payment Amount';
Cells[0, 2] := 'Amount Remaining';
Cells[1, 0] := 'Total';
with AllocationInfo do begin
ColCount := MethodCount + 2;
TotalPayment := 0;
for I := 0 to MethodCount - 1 do begin
Cells[I + 2, 0] := MethodName[I];
Cells[I + 2, 1] := Format(mskCurrency, [MethodAmounts[I] * 1.0]);
ComputeTotalByMethod(I);
Cells[I + 2, 2] := Format(mskCurrency, [MethodAmountsRemaining[I] * 1.0]);
Inc(TotalPayment, MethodAmounts[I]);
end;
Cells[1, 1] := Format(mskCurrency, [TotalPayment * 1.0]);
Cells[1, 2] := Format(mskCurrency, [TotalPaymentRemaining * 1.0]);
end;
end;
with grdCredits do begin
Cells[0, 0] := 'Amount';
Cells[1, 0] := 'Remaining';
with AllocationInfo do begin
RowCount := Credits.Count + 1;
ColCount := MethodCount + 2;
for J := 0 to MethodCount - 1 do
Cells[J + FixedCols, 0] := MethodName[J];
for I := 0 to Credits.Count - 1 do begin
Cells[0, I + 1] := Format(mskCurrency, [Credits[I].Amount * 1.0]);
Cells[1, I + 1] := Format(mskCurrency, [Credits[I].AmountRemaining * 1.0]);
for J := 0 to MethodCount - 1 do
Cells[J + FixedCols, I + 1] := Format(mskCurrency, [Credits[I].PaymentByMethod[J] * 1.0]);
end;
end;
end;
end;
procedure TfrmPaymentAllocation.grdSummaryTopLeftChanged(Sender: TObject);
begin
grdCredits.LeftCol := grdSummary.LeftCol;
end;
procedure TfrmPaymentAllocation.grdCreditsTopLeftChanged(Sender: TObject);
begin
grdSummary.LeftCol := grdCredits.LeftCol;
end;
procedure TfrmPaymentAllocation.grdCreditsSetEditText(Sender: TObject;
ACol, ARow: Longint; const Value: string);
var
Total: LongInt;
I: Integer;
MethodNo: Integer;
CreditNo: Integer;
begin
with grdCredits do
begin
MethodNo := ACol - FixedCols;
CreditNo := ARow - FixedRows;
with AllocationInfo do begin
if Value = '' then
Credits[CreditNo].PaymentByMethod[MethodNo] := 0
else
Credits[CreditNo].PaymentByMethod[MethodNo] := StrToInt(Value);
{ Recompute the amount remaining for the payment method }
with grdSummary do begin
ComputeTotalByMethod(MethodNo);
Cells[FixedCols + MethodNo, 2] := Format(mskCurrency, [MethodAmountsRemaining[MethodNo] * 1.0]);
Cells[1, 2] := Format(mskCurrency, [TotalPaymentRemaining * 1.0]);
end;
{ Recompute the amount remaining for the marker }
Total := Credits[CreditNo].Amount;
for I := 0 to MethodCount - 1 do
Dec(Total, Credits[CreditNo].PaymentByMethod[I]);
grdCredits.Cells[1, FixedRows + CreditNo] := Format(mskCurrency, [Total * 1.0]);
end;
end;
end;
end.